//
// Created by yanhai on 2020/2/20.
//

#include <boost/core/ignore_unused.hpp>
#include "server/http_server.hpp"
#include <spdlog/spdlog.h>

/**
 * test:
 *  curl localhost:8000/v1/test
 *  curl localhost:8000/v1/test -X POST
 * @param request
 * @param response
 * @param arg
 */
static void test(const Request *request, Response *response)
{
    boost::ignore_unused(request);
    response->write("hello world!");
}

int main()
{
    spdlog::default_logger()->set_level(spdlog::level::debug);
    auto &httpServer = HTTPServer::instance();
    httpServer.set_cb("/v1/test", test, EVHTTP_REQ_GET | EVHTTP_REQ_POST);
    httpServer.listen(8000, "0.0.0.0");
    httpServer.start();
    return 0;
}
